<?
//Setup 0.0.2
class sym_setup extends symbiont{
    public function ___admin($design=''){
        $design=$this->_check($design, 'admin');
        $d=new design($design, 'setup', false);
        $this->libraries='';
        $dir=opendir('libraries');
        while($file=readdir($dir)){
            if($file=='.'||$file=='..') continue;
            $f=fopen('libraries/'.$file, "r");
            fgets($f);
            $line=substr(fgets($f), 2);
            preg_match("/([a-zA-Z0-9 ]*) ([0-9]*\.[0-9]*\.[0-9]*)/", $line, $pattern);
            $this->name=substr($file, 0, -8);
            $this->title=$pattern[1];
            $this->version=$pattern[2];
            $this->libraries.=design::run($this->library);
        }
        
        $this->symbionts='';
        $dir=opendir('symbionts');
        while($folder=readdir($dir)){
            if($folder=='.'||$folder=='..') continue;
            if(!file_exists('symbionts/'.$folder.'/config.json')) continue;
            $content=file_get_contents('symbionts/'.$folder.'/config.json');
            $json=json_decode($content);
            $this->name=$folder;
            $l=new label($json->title);
            $title=$l->get();
            $this->title=$title?$title:$json->title;
            $this->version=$json->version;
            $this->symbionts.=design::run($this->symbiont);
        }
        $d->inc();
    }
}
?>